# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(myNpmLib)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include)

if(CMAKE_BUILD_TYPE MATCHES Debug)
    add_definitions(-DDEBUG=1)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -v")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -v")
else()
    add_definitions(-DRELEASE=1)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_NEON=1 -mfpu=neon")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DHAVE_NEON=1")
set(LINK_FLAGS    "${LINK_FLAGS} -rdynamic")

# 支持gnu++11
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

#openssl
set(openssl_dir ${CMAKE_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH})
set(openssl_lib_dir ${openssl_dir}/lib)
include_directories(${openssl_dir}/include)

add_library(libssl STATIC IMPORTED)
set_target_properties(libssl PROPERTIES IMPORTED_LOCATION ${openssl_lib_dir}/libssl.a)
add_library(libcrypto STATIC IMPORTED)
set_target_properties(libcrypto PROPERTIES IMPORTED_LOCATION ${openssl_lib_dir}/libcrypto.a)
#openssl end

# freetype
set(freetype_dir ${CMAKE_SOURCE_DIR}/thirdparty/freetype2/${OHOS_ARCH})
set(freetype_lib_dir ${freetype_dir}/lib)
set(freetype_header_dir ${freetype_dir}/include)

add_library(libfreetype STATIC IMPORTED)
set_target_properties(libfreetype PROPERTIES IMPORTED_LOCATION ${freetype_lib_dir}/libfreetype.a)

include_directories(${freetype_header_dir})
include_directories(${freetype_header_dir}/freetype2)
link_directories(${freetype_lib_dir})
# freetype end


# opencv 4.8.0 Start
set(OPENCV_SDK_PATH ${CMAKE_SOURCE_DIR}/thirdparty/opencv/${OHOS_ARCH})
set(OPENCV_SHARED_LIBS ${OPENCV_SDK_PATH}/lib)
include_directories(${OPENCV_SDK_PATH}/include/opencv4)
link_directories(OPENCV_SHARED_LIBS)

# opencv 4.8.0 END

FILE (GLOB ALL_SOURCES_CSource_filters "CSource/filters/*.cpp")
FILE (GLOB ALL_SOURCES_CSource_util "CSource/util/*.cpp")
FILE (GLOB ALL_SOURCES_CSource "CSource/*.cpp")
include_directories(CSource/filters)
include_directories(CSource/util)
include_directories(CSource)


add_library(
    entry
    SHARED

    napi_init.cpp
)

target_link_libraries(
    entry
    PUBLIC

    ace_napi.z
    hilog_ndk.z
    pixelmap_ndk.z

    libfreetype
)
